# The tmux configure file
# The default  is conflict with vim's hotkey, so unbind it
unbind ^b
set -g prefix ^X
bind a send-prefix

set-option -g status-bg colour235 #base02
set-option -g status-fg red # purple
#set-option -g status-attr default

# set the max buffer lines
set -g history-limit 1048576

set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left-length 20
set -g status-right-length 140

# nvim WARNING focus-events is not enabled. 'autoread' may not work.
set-option -g focus-events on

set -s escape-time 0

set -g clock-mode-style 12

set -g display-time 30000
#set-window-option -g window-status-current-bg green
#set-window-option -g window-status-current-fg black
setw -g window-status-current-format '#[bg=green]#[fg=black]#I:#W#F'

set -g status-left '#[fg=blue,bold]#(hostname) #[default]'
set -g status-right "#[fg=cyan,bold]#(uptime | cut -f 4-5 -d ' ' | cut -f 1 -d ',')#[default] ●  #[fg=yellow,bold]#(date +'%Y-%m-%d %A %H:%M')#[default]"

setw -g mode-keys vi # Use the hotkey option of vi

unbind '"'
bind - splitw -v # Split window with up and down
unbind %
bind | splitw -h # Split window with left and right

# Select the split window
bind k selectp -U # Select up window
bind j selectp -D # Select down window
bind h selectp -L # Select left window
bind l selectp -R # Select right window

# buffer
bind-key ] choose-buffer
bind-key / delete-buffer # delete the top buffer
#bind-key \ list-buffers

bind -n C-h clear-history


# Resize each window
bind-key J resize-pane -D 10
bind-key K resize-pane -U 10
bind-key H resize-pane -L 10
bind-key L resize-pane -R 10

# Send command to all session
#bind-key S setw synchronize-panes
#bind m set monitor-activity
bind S set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
set-option -g monitor-activity on

# Execute command, such as read manpage and look for function of perl
bind m command-prompt "splitw -h 'exec man %%'"
bind v command-prompt "splitw -h 'exec sdcv'"
#bind @ command-prompt "splitw -h 'exec perldoc -f %%'" # NOT Install

# reload config
bind r source-file ~/.tmux.conf.leo \; display-message "Config reloaded..."

# auto window rename
set-option -g allow-rename off
set-window-option -g automatic-rename on #default

# color
set -g default-terminal "screen-256color"
